from flask import Flask, render_template, request

app = Flask(__name__)

# 基础路由
@app.route('/')
def home():
    return render_template('base.html')

# 带参数的路由
@app.route('/user/<name>')
def user(name):
    return f"Hello, {name}!"

# 请求对象演示
@app.route('/info')
def info():
    return f"Request Method: {request.method}"

# 模板继承演示
@app.route('/child')
def child():
    return render_template('child.html')

# 动态模板变量
@app.route('/items')
def items():
    items = ["Apple", "Banana", "Orange"]
    return render_template('items.html', items=items)

if __name__ == '__main__':
    app.run(debug=True)